package recursive.myPow;
/**
 * @Date 2020/03/30
 * @author 王光浩
 * @Thinking 使用哪个迭代实现
 */
public class MyMethodTwo {
	public double myPow(double x, int n) {
		if(n==0)return 1;
		long N=n;
		if(N<0) {
			N=-N;
			x=1/x;
		}
		double ret=1;
		while(N>0) {
			if(N%2!=0)ret*=x;
			x*=x;
			N/=2;
		}
		return ret;
	}	
}
